using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace DataStructure
{
    public class LinkedList1Stack<T> : IStack<T>
    {
        private LinkedList1<T> list;
        
        public LinkedList1Stack()
        {
            list = new LinkedList1<T>();
        }
        
        public int Count => list.Count;

        public bool IsEmpty => list.IsEmpty;
        
        //入栈
        public void Push(T data)
        {
            list.AddFirst(data);
        }
        //出栈
        public T Pop()
        {
            return list.RemoveFirst();
        }

        public T Peek()
        {
            return list.GetFirst();
        }

        public override string ToString()
        {
            return "Stack: top" + list.ToString();
        }
    }
}